fix(apiutil): normalize server URL before appending /api/v1#72
Merged
electather merged 2 commits intomainfrom Mar 16, 2026
Merged
fix(apiutil): normalize server URL before appending /api/v1#72electather merged 2 commits intomainfrom
electather merged 2 commits intomainfrom
Conversation
Extract NormalizeServerURL to trim all trailing slashes before the suffix check. The old TrimSuffix approach only removed one slash, so https://host/api/v1/ would incorrectly become https://host/api/v1/api/v1. Closes #62
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where
https://host/api/v1/(trailing slash after/api/v1) was incorrectly expanded tohttps://host/api/v1/api/v1becausestrings.TrimSuffixonly removed a single trailing slash before the suffix check.Closes #62
Changes
NormalizeServerURL(raw string) stringthat trims all trailing slashes withstrings.TrimRightbefore the/api/v1suffix checkNewAPIClientWithKeyAndTransportwith a call toNormalizeServerURL/api/v1, empty string, and slash-only inputTest plan
go test -v ./...passesgo fmt ./...produces no diffgo buildsucceedsChecklist
--help, comments)